/***
 * 斗地主带自己座位数据类 
 */
var DdzhSeatBase = require('./DdzhSeatBase');
var EnumRole = require('./../../PkCommon/Enum/EnumRole');
var _ = require('./../../FrameWork/we_underscore');
var ClientEveDelegate = require('../../FrameWork/Delegate/ClientEveDelegate');
var ClientPkDelegateType = require('../../PkCommon/Delegate/ClientPkDelegateType');
var PkCardTool = require('./../../PkCommon/FindTool/PkCardTool');
cc.Class({
    extends: DdzhSeatBase,
    ctor() {
        // this.setMoney(_.random(1000, 50000));
        this.roleType = EnumRole.GAMEPLAYER;
        this.sex = _.random(1, 2);
        this.handCards = []; //手牌
    },
    /***出牌动作
     * _outCardInfo:{seatIdx:1,groupType:1,cardIds:[]}
     */
    outCardAct(_outCardInfo) {
        this._super(_outCardInfo);
        var outCards = _outCardInfo.cardIds;
        this.handCards = _.difference(this.handCards, outCards);
        return _.size(this.handCards);
    },
    /***手牌 */
    setHandCards(_handCards) {
        this.handCards = _handCards
    },
    /**往手牌增加牌 */
    addHandCards(_cardsId) {
        this.handCards.push(_cardsId);
        this.handCards = _.flatten(this.handCards);
    },
    /***手牌 */
    getHandCards() {
        return this.handCards;
    },
    getSeatInfo() {
        var info = this._super();
        info.handCards = this.handCards;
        return info;
    },
    /**超时出牌处理 */
    timeOutCardIds() {
        var _cardInfos = PkCardTool.getCardInfos(this.handCards);
        _cardInfos = _.sortBy(_cardInfos, function(_cardInfo) {
            return _cardInfo.value;
        });
        var outCardInfos = [_cardInfos[0]];
        this.handCards = _.difference(this.handCards, [_cardInfos[0].id]);
        return outCardInfos;
    }
});